package com.mineapp.base

import android.os.Bundle

/**
 * Created by mac on 2017/8/1.
 */
class BasePresenterActivity<V: BaseView, P: BasePresenter<V>> : BaseActivity() {

    var mPresenter: P? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mPresenter = initPresenter()
        mPresenter?.mActivity = this
        mPresenter?.setView(bindIView())
    }

    override fun onDestroy() {
        mPresenter?.removeView()
        mPresenter = null
        super.onDestroy()
    }

    open fun bindIView(): V? {
        throw RuntimeException("请绑定View")
    }

    open fun initPresenter(): P? {
        throw RuntimeException("请先初始化presenter")
    }
}